layui.use(['table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
     * 货物搬运管理
     */
    var HxBasicGoodsWH = {
        tableId: "hxBasicGoodsWH"
    };

    /**
     * 初始化表格的列
     */
    HxBasicGoodsWH.initColumn = function () {
        return [[
            {type: 'checkbox'},
            {field: 'goodsNumber', sort: true, title: '编号'},
            {field: 'goodsName', sort: true, title: '商品名称'},
            {field: 'positionNumber', sort: true, title: '库位'},

        ]];
    };

    /**
     * 点击查询按钮
     */
    HxBasicGoodsWH.search = function () {
        var queryData = {};
        queryData['warehouseId'] = $("#storehouseId").val();
        table.reload(HxBasicGoodsWH.tableId, {
            where: queryData, page: {curr: 1},
             done:function () {
            }
        });
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + HxBasicGoodsWH.tableId,
        url: Feng.ctxPath + '/hxBasicGoods/WHList?warehouseId='+$("#storehouseId").val(),
        page: true,
        limit: 60,
        height: "full-60",
        // toolbar: '#toolbarfrom',
        cellMinWidth: 100,
        cols: HxBasicGoodsWH.initColumn()
    });
    HxBasicGoodsWH.exportExcel = function () {
        var checkRows = table.checkStatus(HxBasicGoodsWH.tableId);
        if (checkRows.data.length > 0) {
            table.exportFile(tableResult.config.id, checkRows.data, 'xls');
        } else {
            Feng.error("请选择需要导出的数据！");
        }
    };
    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        HxBasicGoodsWH.search();
    });
    // 导出excel
    $('#btnExp').click(function () {
        HxBasicGoodsWH.exportExcel();
    });
});
